package org.keyuan.service.impl;

import java.util.Date;
import java.util.List;

import org.compass.core.Compass;
import org.compass.core.CompassTemplate;
import org.keyuan.dao.BookDao;
import org.keyuan.entity.Book;
import org.keyuan.service.BookService;
import org.keyuan.util.PageUtil;

public class BookServiceImpl extends ServiceSupport<Book> implements BookService {
	private BookDao bookDao;
	private CompassTemplate compassTemplate;
	public void setCompass(Compass compass){
		this.compassTemplate=new CompassTemplate(compass);
	}
	public void setBookDao(BookDao bookDao) {
		this.bookDao = bookDao;
		this.dao = this.bookDao;
	}
	@Override
	public List<Book> sellTop(Date beginDate) {
		return bookDao.sellTop(beginDate);
	}
	@Override
	public PageUtil<Book> searchBook(String keyword, int curentPage,
			int maxResults) {
		try{
		return compassTemplate.execute(new QuerySearchBook(keyword, curentPage, maxResults));
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
		}

}
